.class public Lcom/netease/util/FileUtils;
.super Ljava/lang/Object;
.source "FileUtils.java"


# direct methods
.method public constructor <init>()V
    .locals 0

    .prologue
    .line 18
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static copyFile(Ljava/io/File;Ljava/io/File;)Z
    .locals 4
    .parameter "srcFile"
    .parameter "destFile"

    .prologue
    .line 111
    const/4 v2, 0x0

    .line 113
    .local v2, result:Z
    :try_start_0
    new-instance v1, Ljava/io/FileInputStream;

    invoke-direct {v1, p0}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    .line 115
    .local v1, in:Ljava/io/InputStream;
    :try_start_1
    invoke-static {v1, p1}, Lcom/netease/util/FileUtils;->copyToFile(Ljava/io/InputStream;Ljava/io/File;)Z
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    move-result v2

    .line 117
    :try_start_2
    invoke-virtual {v1}, Ljava/io/InputStream;->close()V

    .line 122
    .end local v1           #in:Ljava/io/InputStream;
    :goto_0
    return v2

    .line 116
    .restart local v1       #in:Ljava/io/InputStream;
    :catchall_0
    move-exception v3

    .line 117
    invoke-virtual {v1}, Ljava/io/InputStream;->close()V

    .line 118
    throw v3
    :try_end_2
    .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_0

    .line 119
    .end local v1           #in:Ljava/io/InputStream;
    :catch_0
    move-exception v0

    .line 120
    .local v0, e:Ljava/io/IOException;
    const/4 v2, 0x0

    goto :goto_0
.end method

.method public static copyToFile(Ljava/io/InputStream;Ljava/io/File;)Z
    .locals 6
    .parameter "inputStream"
    .parameter "destFile"

    .prologue
    const/4 v4, 0x0

    .line 134
    :try_start_0
    invoke-virtual {p1}, Ljava/io/File;->exists()Z

    move-result v5

    if-eqz v5, :cond_0

    .line 135
    invoke-virtual {p1}, Ljava/io/File;->delete()Z

    .line 137
    :cond_0
    new-instance v3, Ljava/io/FileOutputStream;

    invoke-direct {v3, p1}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    .line 139
    .local v3, out:Ljava/io/OutputStream;
    const/16 v5, 0x1000

    :try_start_1
    new-array v0, v5, [B

    .line 141
    .local v0, buffer:[B
    :goto_0
    invoke-virtual {p0, v0}, Ljava/io/InputStream;->read([B)I
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    move-result v1

    .local v1, bytesRead:I
    if-gez v1, :cond_1

    .line 145
    :try_start_2
    invoke-virtual {v3}, Ljava/io/OutputStream;->close()V
    :try_end_2
    .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_0

    .line 147
    const/4 v4, 0x1

    .line 149
    .end local v0           #buffer:[B
    .end local v1           #bytesRead:I
    .end local v3           #out:Ljava/io/OutputStream;
    :goto_1
    return v4

    .line 142
    .restart local v0       #buffer:[B
    .restart local v1       #bytesRead:I
    .restart local v3       #out:Ljava/io/OutputStream;
    :cond_1
    const/4 v5, 0x0

    :try_start_3
    invoke-virtual {v3, v0, v5, v1}, Ljava/io/OutputStream;->write([BII)V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    goto :goto_0

    .line 144
    .end local v0           #buffer:[B
    .end local v1           #bytesRead:I
    :catchall_0
    move-exception v5

    .line 145
    :try_start_4
    invoke-virtual {v3}, Ljava/io/OutputStream;->close()V

    .line 146
    throw v5
    :try_end_4
    .catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_0

    .line 148
    .end local v3           #out:Ljava/io/OutputStream;
    :catch_0
    move-exception v2

    .line 149
    .local v2, e:Ljava/io/IOException;
    goto :goto_1
.end method

.method public static createFile(Ljava/io/File;)V
    .locals 2
    .parameter "file"

    .prologue
    .line 87
    invoke-virtual {p0}, Ljava/io/File;->exists()Z

    move-result v1

    if-eqz v1, :cond_0

    .line 88
    invoke-virtual {p0}, Ljava/io/File;->delete()Z

    .line 91
    :cond_0
    invoke-virtual {p0}, Ljava/io/File;->getParentFile()Ljava/io/File;

    move-result-object v0

    .line 92
    .local v0, parent:Ljava/io/File;
    invoke-virtual {v0}, Ljava/io/File;->exists()Z

    move-result v1

    if-nez v1, :cond_1

    .line 93
    invoke-virtual {v0}, Ljava/io/File;->mkdirs()Z

    .line 97
    :cond_1
    :try_start_0
    invoke-virtual {p0}, Ljava/io/File;->createNewFile()Z
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    .line 101
    :goto_0
    return-void

    .line 98
    :catch_0
    move-exception v1

    goto :goto_0
.end method

.method public static createFile(Ljava/lang/String;)V
    .locals 1
    .parameter "path"

    .prologue
    .line 76
    new-instance v0, Ljava/io/File;

    invoke-direct {v0, p0}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-static {v0}, Lcom/netease/util/FileUtils;->createFile(Ljava/io/File;)V

    .line 78
    return-void
.end method

.method public static delete(Ljava/io/File;)V
    .locals 5
    .parameter "file"

    .prologue
    .line 35
    if-eqz p0, :cond_0

    invoke-virtual {p0}, Ljava/io/File;->exists()Z

    move-result v2

    if-eqz v2, :cond_0

    .line 36
    invoke-virtual {p0}, Ljava/io/File;->isDirectory()Z

    move-result v2

    if-eqz v2, :cond_2

    .line 37
    invoke-virtual {p0}, Ljava/io/File;->listFiles()[Ljava/io/File;

    move-result-object v1

    .line 38
    .local v1, subs:[Ljava/io/File;
    if-eqz v1, :cond_0

    .line 39
    array-length v3, v1

    const/4 v2, 0x0

    :goto_0
    if-lt v2, v3, :cond_1

    .line 47
    .end local v1           #subs:[Ljava/io/File;
    :cond_0
    :goto_1
    return-void

    .line 39
    .restart local v1       #subs:[Ljava/io/File;
    :cond_1
    aget-object v0, v1, v2

    .line 40
    .local v0, sub:Ljava/io/File;
    invoke-virtual {v0}, Ljava/io/File;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-static {v4}, Lcom/netease/util/FileUtils;->delete(Ljava/lang/String;)V

    .line 39
    add-int/lit8 v2, v2, 0x1

    goto :goto_0

    .line 44
    .end local v0           #sub:Ljava/io/File;
    .end local v1           #subs:[Ljava/io/File;
    :cond_2
    invoke-static {p0}, Lcom/netease/util/FileUtils;->deleteFile(Ljava/io/File;)V

    goto :goto_1
.end method

.method public static delete(Ljava/lang/String;)V
    .locals 1
    .parameter "path"

    .prologue
    .line 26
    new-instance v0, Ljava/io/File;

    invoke-direct {v0, p0}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-static {v0}, Lcom/netease/util/FileUtils;->delete(Ljava/io/File;)V

    .line 27
    return-void
.end method

.method public static deleteFile(Ljava/io/File;)V
    .locals 1
    .parameter "file"

    .prologue
    .line 64
    if-eqz p0, :cond_0

    invoke-virtual {p0}, Ljava/io/File;->exists()Z

    move-result v0

    if-eqz v0, :cond_0

    .line 65
    invoke-virtual {p0}, Ljava/io/File;->delete()Z

    .line 67
    :cond_0
    return-void
.end method

.method public static deleteFile(Ljava/lang/String;)V
    .locals 1
    .parameter "path"

    .prologue
    .line 55
    new-instance v0, Ljava/io/File;

    invoke-direct {v0, p0}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-static {v0}, Lcom/netease/util/FileUtils;->delete(Ljava/io/File;)V

    .line 56
    return-void
.end method
